# -*- coding: UTF-8 -*-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# from appraisals.consql import conn
from jixiao.connetsql import conn
import time

start = time.time()
df = pd.read_sql('select  TableID,CreateTime from zwyczc where datediff(d,CreateTime,getdate()) <=365 ;', con=conn)
df['Time'] = df['CreateTime'].astype('str').str[10:13].astype('int')
df['Date'] = df['CreateTime'].astype('str').str[:10]
data1 = df['Time'] >= 18  #开始时间
data2 = df['Time'] <= 20  #结束时间
df2 = df.loc[data1&data2].groupby('Date',as_index=False)['TableID'].count()  #20点后每天的支撑量
# df3 = df.groupby('Time',as_index=False)['TableID'].count()  #按时间段维度进行统计
# print(df.info())
x = df2['Date']
y = df2['TableID']
plt.plot(x,y)
plt.xlabel("Date")
plt.ylabel("Count")

# x =df3['Time']
# y =df3['TableID']
# plt.plot(x,y)
# plt.xlabel('Time')
# plt.ylabel('Count')
plt.show()
print(df.info())
print(time.time()-start)